import resources.Constants;

/* [start] 	Loads the APE grade from the database */
loadAPEGrade(){
	List apeGrades = new registnet.dao.GradePeer().getAPEGradeByStudent(DAOStudent.getStudentId());
	Iterator i = apeGrades.iterator();
	while(i.hasNext()){
		registnet.dao.Grade grade = i.next();
		if(grade.getCourse().getCourseCode().equals("ENG 1(AH)")) liENG1.setChecked(true);
		if(grade.getCourse().getCourseCode().equals("ENG 2(AH)")) liENG2.setChecked(true);
		if(grade.getCourse().getCourseCode().equals("HUM 1(AH)")) liHUM1.setChecked(true);
		if(grade.getCourse().getCourseCode().equals("BIO 1")) liBIO1.setChecked(true);
		if(grade.getCourse().getCourseCode().equals("BIO 2")) liBIO2.setChecked(true);
		if(grade.getCourse().getCourseCode().equals("MATH 11")) liMATH11.setChecked(true);
		if(grade.getCourse().getCourseCode().equals("MATH 14")) liMATH14.setChecked(true);
		if(grade.getCourse().getCourseCode().equals("MATH 17")) liMATH17.setChecked(true);
		if(grade.getCourse().getCourseCode().equals("CHEM 16")) liCHEM16.setChecked(true);
		if(grade.getCourse().getCourseCode().equals("HIST 1(SSP)")) liHIST1.setChecked(true);
		if(grade.getCourse().getCourseCode().equals("HIST 2(SSP)")) liHIST2.setChecked(true);
		if(grade.getCourse().getCourseCode().equals("NASC 1(MST)")) liNASC1.setChecked(true);
	}
}
/* [end] */

/* [start] 	Updates the changes in the APE grades in the database */
accredit(){
	
	List apeGrades = new registnet.dao.GradePeer().getAPEGradeByStudent(DAOStudent.getStudentId());
	Iterator i = apeGrades.iterator();
	while(i.hasNext()){
		registnet.dao.Grade grade = i.next();
		new registnet.dao.GradePeer().deleteGrade(grade.getGradeId());
	}
	if(liENG1.isChecked()){
		try{
			registnet.dao.Course daoCourse = new registnet.dao.CoursePeer().getCourse(liENG1.getLabel());
			new registnet.dao.GradePeer().createNewGrade(daoCourse.getCourseId(), "APE", Constants.MAP_GRADE_KEY.get("PASS"), DAOStudent.getStudentId(), 1, Integer.parseInt(DAOStudent.getStudentNumber().substring(0,4)), "", daoCourse.getUnits());
		}catch(Exception e){}
	}
	if(liENG2.isChecked()){
		try{
			registnet.dao.Course daoCourse = new registnet.dao.CoursePeer().getCourse(liENG2.getLabel());
			new registnet.dao.GradePeer().createNewGrade(daoCourse.getCourseId(), "APE", Constants.MAP_GRADE_KEY.get("PASS"), DAOStudent.getStudentId(), 1, Integer.parseInt(DAOStudent.getStudentNumber().substring(0,4)), "", daoCourse.getUnits());
		}catch(Exception e){}
	}
	if(liHUM1.isChecked()){
		try{
			registnet.dao.Course daoCourse = new registnet.dao.CoursePeer().getCourse(liHUM1.getLabel());
			new registnet.dao.GradePeer().createNewGrade(daoCourse.getCourseId(), "APE", Constants.MAP_GRADE_KEY.get("PASS"), DAOStudent.getStudentId(), 1, Integer.parseInt(DAOStudent.getStudentNumber().substring(0,4)), "", daoCourse.getUnits());
		}catch(Exception e){}
	}
	if(liBIO1.isChecked()){
		try{
			registnet.dao.Course daoCourse = new registnet.dao.CoursePeer().getCourse(liBIO1.getLabel());
			new registnet.dao.GradePeer().createNewGrade(daoCourse.getCourseId(), "APE", Constants.MAP_GRADE_KEY.get("PASS"), DAOStudent.getStudentId(), 1, Integer.parseInt(DAOStudent.getStudentNumber().substring(0,4)), "", daoCourse.getUnits());
		}catch(Exception e){}
	}
	if(liBIO2.isChecked()){
		try{
			registnet.dao.Course daoCourse = new registnet.dao.CoursePeer().getCourse(liBIO2.getLabel());
			new registnet.dao.GradePeer().createNewGrade(daoCourse.getCourseId(), "APE", Constants.MAP_GRADE_KEY.get("PASS"), DAOStudent.getStudentId(), 1, Integer.parseInt(DAOStudent.getStudentNumber().substring(0,4)), "", daoCourse.getUnits());
		}catch(Exception e){}
	}
	if(liMATH11.isChecked()){
		try{
			registnet.dao.Course daoCourse = new registnet.dao.CoursePeer().getCourse(liMATH11.getLabel());
			new registnet.dao.GradePeer().createNewGrade(daoCourse.getCourseId(), "APE", Constants.MAP_GRADE_KEY.get("PASS"), DAOStudent.getStudentId(), 1, Integer.parseInt(DAOStudent.getStudentNumber().substring(0,4)), "", daoCourse.getUnits());
		}catch(Exception e){}
	}
	if(liMATH14.isChecked()){
		try{
			registnet.dao.Course daoCourse = new registnet.dao.CoursePeer().getCourse(liMATH14.getLabel());
			new registnet.dao.GradePeer().createNewGrade(daoCourse.getCourseId(), "APE", Constants.MAP_GRADE_KEY.get("PASS"), DAOStudent.getStudentId(), 1, Integer.parseInt(DAOStudent.getStudentNumber().substring(0,4)), "", daoCourse.getUnits());
		}catch(Exception e){}
	}
	if(liMATH17.isChecked()){
		try{
			registnet.dao.Course daoCourse = new registnet.dao.CoursePeer().getCourse(liMATH17.getLabel());
			new registnet.dao.GradePeer().createNewGrade(daoCourse.getCourseId(), "APE", Constants.MAP_GRADE_KEY.get("PASS"), DAOStudent.getStudentId(), 1, Integer.parseInt(DAOStudent.getStudentNumber().substring(0,4)), "", daoCourse.getUnits());
		}catch(Exception e){}
	}
	if(liCHEM16.isChecked()){
		try{
			registnet.dao.Course daoCourse = new registnet.dao.CoursePeer().getCourse(liCHEM16.getLabel());
			new registnet.dao.GradePeer().createNewGrade(daoCourse.getCourseId(), "APE", Constants.MAP_GRADE_KEY.get("PASS"), DAOStudent.getStudentId(), 1, Integer.parseInt(DAOStudent.getStudentNumber().substring(0,4)), "", daoCourse.getUnits());
		}catch(Exception e){}
	}
	if(liHIST1.isChecked()){
		try{
			registnet.dao.Course daoCourse = new registnet.dao.CoursePeer().getCourse(liHIST1.getLabel());
			new registnet.dao.GradePeer().createNewGrade(daoCourse.getCourseId(), "APE", Constants.MAP_GRADE_KEY.get("PASS"), DAOStudent.getStudentId(), 1, Integer.parseInt(DAOStudent.getStudentNumber().substring(0,4)), "", daoCourse.getUnits());
		}catch(Exception e){}
	}
	if(liHIST2.isChecked()){
		try{
			registnet.dao.Course daoCourse = new registnet.dao.CoursePeer().getCourse(liHIST2.getLabel());
			new registnet.dao.GradePeer().createNewGrade(daoCourse.getCourseId(), "APE", Constants.MAP_GRADE_KEY.get("PASS"), DAOStudent.getStudentId(), 1, Integer.parseInt(DAOStudent.getStudentNumber().substring(0,4)), "", daoCourse.getUnits());
		}catch(Exception e){}
	}
	if(liNASC1.isChecked()){
		try{
			registnet.dao.Course daoCourse = new registnet.dao.CoursePeer().getCourse(liNASC1.getLabel());
			new registnet.dao.GradePeer().createNewGrade(daoCourse.getCourseId(), "APE", Constants.MAP_GRADE_KEY.get("PASS"), DAOStudent.getStudentId(), 1, Integer.parseInt(DAOStudent.getStudentNumber().substring(0,4)), "", daoCourse.getUnits());
		}catch(Exception e){}
	}
	
}
/* [end] */


